﻿using Common;
using Network.UpdateData;
using System.Net.Sockets;

namespace SFJDService.SocketHandle
{
    /// <summary>
    /// 接收到用户界面发送来的添加注册的请求
    /// </summary>
    public class PH04User : PacketHandle
    {
        public PH04User(Socket socket, Packet packet) : base(socket, packet) { }

        protected override void Handle()
        {
            ClassConfig config = new ClassConfig();
            config.DecodingFromString(Message);
            Runtime.thisUser.Copy(config);
            if (Runtime.thisUser.IsAdmin)
            {
                Runtime.xmlUsers.AddUser(config);
                Delay(100);
                for(int i = 0; i < 5; i++)
                {
                    Launcher.SendMsg2All(typeof(PH04AddUserOridary).GetDictianaryKey(), config.Coding2String());
                    Delay(500);
                }
            }
            else
            {
                Launcher.SendMsg2All(typeof(PH04AddUserAdmin).GetDictianaryKey(), Message);
            }
        }
    }
}
